<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视频转码</title>
</head>

<body>
    <video controls src=""></video>
    <input type="text" placeholder="请输入视频地址" value="https://file.thinkcar.com/app_services/2024-02-28/20240228095557412877.mp4">
    <button onclick="transcode()">转码</button>
    <script>
        const video = document.querySelector('video')
        const input = document.querySelector('input')

        function transcode() {
            const videoUrl = input.value;

            fetch("http://42.193.231.115:9999/transcode", {
                method: "POST",
                headers: {
                    'Content-Type': 'application/json',
                    'Accept':'video/x-ms-wmv'
                },
                body: JSON.stringify({
                    videoUrl
                }),
            }).then(res => res.blob()).then(blob => {
                console.log(blob);
                const url = URL.createObjectURL(blob);
                console.log(url);
                video.src = url;
            })
        }
    </script>
</body>

</html>